package cn.wolfcode.luowowo.common.util;


import cn.wolfcode.luowowo.common.exception.LogicException;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class AssertUtil {

    public static void hasLength(String value, String msg) {
        if (value == null || "".equals(value.trim())) {
            throw new LogicException(msg);
        }
    }

    public static void isEquals(String password, String rpassword, String msg) {
        if (password == null || rpassword == null) {
            throw new LogicException("参数不能为空");
        }
        if (!password.equals(rpassword)) {
            throw new LogicException(msg);
        }
    }


    public static boolean isMobileNO(String mobiles) {

        Pattern p = Pattern.compile("^((13[0-9])|(15[^4])|(18[0-9])|(17[0-9])|(147))\\d{8}$");
        Matcher m = p.matcher(mobiles);
        return m.matches();
    }
}

